﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.Party.PartyComponents.BanditPartyComponent
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using System.Collections.Generic;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.Party.PartyComponents
{
  public class BanditPartyComponent : WarPartyComponent
  {
    [CachedData]
    private TextObject _cachedName;
    [SaveableField(3)]
    private readonly Settlement _relatedSettlement;

    internal static void AutoGeneratedStaticCollectObjectsBanditPartyComponent(
      object o,
      List<object> collectedObjects)
    {
      ((PartyComponent) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this._relatedSettlement);
      collectedObjects.Add((object) this.Hideout);
    }

    internal static object AutoGeneratedGetMemberValueHideout(object o)
    {
      return (object) ((BanditPartyComponent) o).Hideout;
    }

    internal static object AutoGeneratedGetMemberValueIsBossParty(object o)
    {
      return (object) ((BanditPartyComponent) o).IsBossParty;
    }

    internal static object AutoGeneratedGetMemberValue_relatedSettlement(object o)
    {
      return (object) ((BanditPartyComponent) o)._relatedSettlement;
    }

    public static MobileParty CreateBanditParty(
      string stringId,
      Clan clan,
      Hideout hideout,
      bool isBossParty)
    {
      return MobileParty.CreateParty(stringId, (PartyComponent) new BanditPartyComponent(hideout, isBossParty), (PartyComponent.OnPartyComponentCreatedDelegate) (mobileParty => mobileParty.ActualClan = clan));
    }

    public static MobileParty CreateLooterParty(
      string stringId,
      Clan clan,
      Settlement relatedSettlement,
      bool isBossParty)
    {
      return MobileParty.CreateParty(stringId, (PartyComponent) new BanditPartyComponent(relatedSettlement), (PartyComponent.OnPartyComponentCreatedDelegate) (mobileParty => mobileParty.ActualClan = clan));
    }

    [SaveableProperty(1)]
    public Hideout Hideout { get; private set; }

    [SaveableProperty(2)]
    public bool IsBossParty { get; private set; }

    public override Settlement HomeSettlement
    {
      get => this.Hideout == null ? this._relatedSettlement : this.Hideout.Settlement;
    }

    public override Hero PartyOwner => this.MobileParty.ActualClan?.Leader;

    public override TextObject Name
    {
      get
      {
        TextObject name = Game.Current.IsDevelopmentMode ? new TextObject(this.MobileParty.StringId) : this._cachedName ?? (this._cachedName = this.Hideout != null ? this.Hideout.MapFaction.Name : this.MobileParty.MapFaction.Name);
        name.SetTextVariable("IS_BANDIT", 1);
        return name;
      }
    }

    protected internal BanditPartyComponent(Hideout hideout, bool isBossParty)
    {
      this.Hideout = hideout;
      this.IsBossParty = isBossParty;
    }

    protected internal BanditPartyComponent(Settlement relatedSettlement)
    {
      this._relatedSettlement = relatedSettlement;
    }

    public void SetHomeHideout(Hideout hideout) => this.Hideout = hideout;

    public override void ClearCachedName() => this._cachedName = (TextObject) null;
  }
}
